package org.thotheolh.sweatkeeper.ui;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;
import java.awt.Color;

public class Main {

	private JFrame frmSweatkeeperDesktop;
	private JTabbedPane mainTab;
	private JPanel bottomPanel;
	private JLabel statsLbl;

	/**
	 * Create the application.
	 */
	public Main() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmSweatkeeperDesktop = new JFrame();
		frmSweatkeeperDesktop.setTitle("SweatKeeper Desktop");
		frmSweatkeeperDesktop.setBounds(100, 100, 800, 600);
		frmSweatkeeperDesktop.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frmSweatkeeperDesktop.getContentPane().setLayout(new BorderLayout());
		
		mainTab = new JTabbedPane();
		mainTab.setTabPlacement(JTabbedPane.BOTTOM);
		
		mainTab.addTab("Workout",new WorkoutPanel());
		mainTab.addTab("Template",new TemplatePanel());
		mainTab.addTab("Equipment", new EquipmentPanel());
		
		frmSweatkeeperDesktop.getContentPane().add(mainTab, BorderLayout.CENTER);
		
		bottomPanel = new JPanel();
		bottomPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.BLACK, null, null, null));
		FlowLayout flowLayout = (FlowLayout) bottomPanel.getLayout();
		flowLayout.setAlignment(FlowLayout.LEADING);
		frmSweatkeeperDesktop.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
		
		statsLbl = new JLabel("Idle.");
		statsLbl.setHorizontalAlignment(SwingConstants.TRAILING);
		bottomPanel.add(statsLbl);
	}
	
	public void show(){
		frmSweatkeeperDesktop.setVisible(true);
	}
	
	public void hide(){
		frmSweatkeeperDesktop.setVisible(false);
	}
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Main window = new Main();
					window.frmSweatkeeperDesktop.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

}
